Hello, I am trying to write to an S3 bucket with a...
# troubleshooting
n
Hello, I am trying to write to an S3 bucket with all the permission(S3*) for Flink 1.18 local standalone cluster, and the credentials are correct, checked via python code. And I have added the following in flink-conf.yaml # AWS secrets s3.access-key: access-key s3.secret-key: secret-key s3.endpoint.region: region s3.path.style.access: true s3a.access-key: access-key s3a.secret-key: secret-key s3a.endpoint.region: region s3a.path.style.access: true It fails with the error: initiate MultiPartUpload on folder/2024-01-10--20/part-383b0eed-e86e-4cbe-9375-b3696affec77-0: com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: request id; S3 Extended Request ID: S3 extended request ID; Proxy: null), S3 Extended Request ID: S3 extended request IDAccessDenied. Am I missing any other config? Thanks in advance
Copy code
String path = "s3a://bucket_name/folder_path";

        DefaultRollingPolicyString, String rollingPolicy = DefaultRollingPolicy.builder()
                .withRolloverInterval(Duration.ofMinutes(1))
                .withInactivityInterval(Duration.ofMinutes(5))
                .withMaxPartSize(MemorySize.ofMebiBytes(1024))
                .build();

        final FileSinkString sink = FileSink
                .forRowFormat(new Path(path), new SimpleStringEncoderString("UTF-8"))
                .withRollingPolicy(
                        rollingPolicy)
                .build();
       stream.sinkTo(sink).name("file_sink");
πŸ‘€ 1
r
Im also facing the same issue.. any suggestion for the above error ?
n
The above issue was due to a Multi Part Upload Permission issue for our scenario, so the resolution was also adding all permissions for the IAM role used in the Apache Flink Job. Also exposing the AWS environment variables directly also works as follows:
AWS_ACCESS_KEY_ID="aws_access_key"
AWS_SECRET_ACCESS_KEY="aws_secret_access_key"
Apart from this also set the checkpointing interval, in case the permission issue is resolved but you are still not able to see data in S3:
Copy code
env.enableCheckpointing(1000);
πŸ‘€ 1
j
This might help someone else facing a similar issue (if you're using a hadoop filesink for flink deployments on EKS). What worked for me was to place the following in my flink config: fs.s3a.aws.credentials.provider: com.amazonaws.auth.WebIdentityTokenCredentialsProvider and to ensure that you have the env variable "AWS_WEB_IDENTITY_TOKEN_FILE" set in your flink deployment.
πŸ™Œ 1